package cn.tedu.csmall.product.webapi.controller;

import cn.tedu.csmall.commoms.response.JsonResult;
import cn.tedu.csmall.pojo.dto.BrandAddNewDTO;
import cn.tedu.csmall.pojo.vo.BrandAddNewVO;
import cn.tedu.csmall.product.service.IBrandService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


@Api(tags = "2. 品牌管理模块")
@RestController
@RequestMapping("/brands")
public class BrandController {

    @Autowired
    private IBrandService brandService;

    /**
     * 增加品牌
     */
    @ApiOperationSupport(order = 10)
    @ApiOperation(value = "增加品牌", notes = "需要商品后台【写】权限：/pms/product/update")
    @PostMapping("/add-new")
    public JsonResult<BrandAddNewVO> addNew(@Valid BrandAddNewDTO brandAddnewDTO) {
        Long id = brandService.addNew(brandAddnewDTO);
        return JsonResult.ok(new BrandAddNewVO().setId(id));
    }

}
